﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using Microsoft.JCI.Common.Entity;
using Microsoft.JCI.Bll;

namespace Microsoft.JCI.Portal
{
    public partial class Navigate : BasePage
    {
        public override bool IsCheckAccessible
        {
            get
            {
                return false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<SysFunctionEntity> FuncEntities = new SystemBll().LoadTreeFunctionEntitiesByUserID(CurrentUserID);

                Session["Func"] = FuncEntities;
 
                FuncEntities = FuncEntities.FindAll(delegate(SysFunctionEntity ent) { return ent.FFuncID == null; });
                listNavigate.DataSource = FuncEntities;
                listNavigate.DataBind();
            }
        }
 

        protected void listNavigate_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                List<SysFunctionEntity> FuncEntities = Session["Func"] as List<SysFunctionEntity>;
                List<SysFunctionEntity> FuncCurrEntities = FuncEntities.FindAll(delegate(SysFunctionEntity ent) { return ent.FFuncID == listNavigate.DataKeys[e.Item.ItemIndex].ToString(); });

                Repeater sub = e.Item.FindControl("rptSubNavigate") as Repeater;
                sub.DataSource = FuncCurrEntities;
                sub.DataBind();
            }
        }
    }
}
